odoo.define('custom.del.tree', function (require) {
    "use strict";
    var ListController = require('web.ListController');
    var ListView = require('web.ListView');
    var viewRegistry = require('web.view_registry');
    var DelListController = ListController.extend({
        buttons_template: 'custom.del.buttons',
        events: _.extend({}, ListController.prototype.events, {
            'click .o_button_custom_del': '_onButtonSend',
        }),
        _onButtonSend: function () {
            var self = this;

            var records = _.map(self.selectedRecords, function (id) {
                return self.model.localData[id];
            });
            var ids = _.pluck(records, 'res_id');
            self.do_action({
                    type: "ir.actions.act_window",
                    name: "批量删除",
                    res_model: "wizard.delete.record",
                    views: [[false, 'form']],
                    target: 'new',
                    context: {
                        ids: ids,
                        'modelName':self.modelName,
                        "viewId":self.viewId,
                        "viewType":self.viewType
                    },
                },
                {
                    on_reverse_breadcrumb: function () {
                        self.reload();
                    },
                    on_close: function () {
                        self.reload();
                    }
                }
            );
            //
        }
    });
    var DeleteListView = ListView.extend({
        config: _.extend({}, ListView.prototype.config, {
            Controller: DelListController,
        }),
    });

    viewRegistry.add('custom_del_tree', DeleteListView);
});